package One;

import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		PersonSortable[] p = new PersonSortable[n];
		for (int i = 0; i < n; i++) {
			p[i] = new PersonSortable(scan.next(), scan.nextInt());
		}
		Arrays.sort(p);
		for (int i = 0; i < p.length; i++) {
			System.out.println(p[i]);
		}
		System.out.println(Arrays.toString(PersonSortable.class.getInterfaces()));
		scan.close();
	}

}